import request from '@/utils/request'

// 分页
export function pagingCommander(query) {
  return request({
    url: '/user/villageCommander/paging',
    method: 'get',
    params: query
  })
}

// 获取详情
export function getVillageCommander(commanderId) {
  return request({
    url: '/user/villageCommander/getVillageCommander',
    method: 'get',
    params: {
      commanderId
    }
  })
}

/**
 * 通过/拒绝
 * @param data
 */
export function saveCommander(entity) {
  return request({
    url: '/user/villageCommander/save',
    method: 'post',
    data: entity
  })
}

/**
 * 团长状态操作
 * @param data
 */
export function saveCommanderType(commanderId, commanderType) {
  const entity = {
    commanderId: commanderId,
    commanderType: commanderType
  }
  return request({
    url: '/user/villageCommander/saveCommanderType',
    method: 'post',
    params: entity
  })
}

// 查询区县内的小区列表
export function listByDistrictCode(query) {
  return request({
    url: '/user/villageCommander/listByDistrictCode',
    method: 'get',
    params: query
  })
}

// 查询团长关联的小区列表
export function listByCommanderId(query) {
  return request({
    url: '/user/villageCommander/listByCommanderId',
    method: 'get',
    params: query
  })
}

// 更新团长关联的小区列表
export function updateCommanderVillageRelate(villages) {
  return request({
    url: '/user/villageCommander/updateCommanderVillageRelate',
    method: 'post',
    data: villages
  })
}
/**
 * 获取团长绑定码
 * @param {Object} query
 */
export function getCommanderBindCode(query) {
  return request({
    url: '/user/villageCommander/getCommanderBindCode',
    method: 'get',
    params: query
  })
}
